/**
 * Description:
 * Class Name:ReplaceTest
 * Date:2022/5/3 13:57
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第15章_输入输出._15_8_Java9改进的对象序列化._15_8_5_自定义序列化;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class ReplaceTest {
    public static void main(String[] args) {
        try (
                var oos = new ObjectOutputStream(new FileOutputStream("Chapter_15_8_5_Replace.txt"));
                var ois = new ObjectInputStream(new FileInputStream("Chapter_15_8_5_Replace.txt"))
                ){
            var per = new ReplacePerson("Replaced孙悟空", 500);
            oos.writeObject(per);
            var list = (ArrayList)ois.readObject();
            System.out.println(list);
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}
//有参数的构造器
//[Replaced孙悟空, 500]